/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "executed_rules")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ExecutedRules.findAll", query = "SELECT e FROM ExecutedRules e"),
    @NamedQuery(name = "ExecutedRules.findById", query = "SELECT e FROM ExecutedRules e WHERE e.id = :id"),
    @NamedQuery(name = "ExecutedRules.findByExecutionTime", query = "SELECT e FROM ExecutedRules e WHERE e.executionTime = :executionTime"),
    @NamedQuery(name = "ExecutedRules.findByExecutionResult", query = "SELECT e FROM ExecutedRules e WHERE e.executionResult = :executionResult")})
public class ExecutedRules implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Basic(optional = false)
    @Column(name = "ExecutionTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date executionTime;
    @Column(name = "ExecutionResult")
    private Boolean executionResult;
    @JoinColumn(name = "Id_PredicateViolated", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Predicate idPredicateViolated;
    @JoinColumn(name = "Id_GPIKPIViolated", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private GpiKpi idGPIKPIViolated;
    @JoinColumn(name = "Id_Rule", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Rule idRule;

    public ExecutedRules() {
    }

    public ExecutedRules(String id) {
        this.id = id;
    }

    public ExecutedRules(String id, Date executionTime) {
        this.id = id;
        this.executionTime = executionTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getExecutionTime() {
        return executionTime;
    }

    public void setExecutionTime(Date executionTime) {
        this.executionTime = executionTime;
    }

    public Boolean getExecutionResult() {
        return executionResult;
    }

    public void setExecutionResult(Boolean executionResult) {
        this.executionResult = executionResult;
    }

    public Predicate getIdPredicateViolated() {
        return idPredicateViolated;
    }

    public void setIdPredicateViolated(Predicate idPredicateViolated) {
        this.idPredicateViolated = idPredicateViolated;
    }

    public GpiKpi getIdGPIKPIViolated() {
        return idGPIKPIViolated;
    }

    public void setIdGPIKPIViolated(GpiKpi idGPIKPIViolated) {
        this.idGPIKPIViolated = idGPIKPIViolated;
    }

    public Rule getIdRule() {
        return idRule;
    }

    public void setIdRule(Rule idRule) {
        this.idRule = idRule;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ExecutedRules)) {
            return false;
        }
        ExecutedRules other = (ExecutedRules) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.ExecutedRules[ id=" + id + " ]";
    }
    
}
